<?php
/**
 * 加入我们
 */
namespace app\admin\controller;
use app\admin\model\MemberDonation as MemberDonationModel;
use app\admin\model\Member as MemberModel;

class MemberDonation extends Admin
{
    function index(){
        if (!$this->request->isPost()){
            return view('index');
        }else{
            $limit  = $this->request->post('limit', 20, 'intval');
            $page = $this->request->post('page', 1, 'intval');
            $order  = $this->request->post('order', '', 'serach_in');	//排序字段
            $sort  = $this->request->post('sort', '', 'serach_in');		//排序方式

            $orderby = ($sort && $order) ? $sort.' '.$order : 'id desc';
            //获取用户等级列表
            $res = MemberDonationModel::getList($orderby,$limit,$page);
            foreach ($res['data'] as $k => $v){
                $res['data'][$k]['images'] = explode(',', $v['images']);
                $member = MemberModel::getDetails($v['mid']);
                $res['data'][$k]['username'] = !empty($member) ? $v['mid'].' | '.$member['username'] : $v['mid'];
            }

            $data['status'] = 200;
            $data['data'] = $res;
            return json($data);
        }
    }
}